<template>
    <div>
        <h1>this is child component</h1>
        <button @click="toParent">向父组件传值</button>
    </div>
</template>
 
 
<script>
export default {
    data() {
        return {
            data1: '子组件的数据'
        }
    },
    methods: {
        toParent:function() {
            this.$emit('event1', this.data1)
        }
    }
}
</script>
 
<style scoped>
    div {
        border: 1px solid red;
    }
</style>